<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
        <style>
            .vm{
                position: absolute;
                left: 0;
                right: 0;
                top: 0;
                bottom: 0;
                margin: auto;
            }
            /*.box{
                padding: 40px;
                background-color: #fc0;
            }*/
             .box{
                /*width: 400px;*/
                height: 400px;
                background-color: #fc0;
            } 
        </style>
    </head>
    <body>
        <h1>绝对定位，上下左右为0,外边距自动，需要设置元素的宽高才能垂直水平居中</h1>
        <div class="vm box">好好学习</div>
    </body>
</html>